package com.gluck.cases.common.utils.utils;

/**
 * @ClassName MethodUtil
 * @Desc 反射方法工具类
 * @Author shiyongzhe
 * @Date 2022/5/28 - 2:31 下午
 **/
public class MethodUtil {

    private static final String SET_PREFIX = "set";

    private static final String GET_PREFIX = "get";

    /**
     * 功能描述: 首个字母转为大写组装setter
     * @Params [field]
     * @Return java.lang.String
     * @Author I`m Gluck
     * @Date 2022/5/28
     */
    public static String capitalize(String field){
        if (field == null || field.length() == 0) {
            return field;
        }
        String s = field.substring(0, 1).toUpperCase();
        return s + field.substring(1);
    }

    public static String setMethodName(String propertyName) {
        return SET_PREFIX + capitalize(propertyName);
    }
    public static String getMethodName(String propertyName) {
        return GET_PREFIX + capitalize(propertyName);
    }
}
